package com.mfl.controller.user;

import com.mfl.common.PageResult;
import com.mfl.common.Result;
import com.mfl.pojo.dto.TestExamPageQueryDTO;
import com.mfl.pojo.vo.TestCategoryVO;
import com.mfl.service.TestCategoryService;
import com.mfl.service.TestExamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userTestExamController")
@RequestMapping("/cky/user/testExam")
@Slf4j
public class TestExamController {

    @Autowired
    private TestCategoryService testCategoryService;
    @Autowired
    private TestExamService testExamService;

    /**
     * 查询所有启动的测试分类
     * @return
     */
    @GetMapping("/getTestCategoryAll")
    public Result<List<TestCategoryVO>> getTestCategoryAll(){
        log.info("查询所有启动的测试分类");
        return Result.success("", testCategoryService.getAll());
    }

    /**
     * 分页查询测试试卷
     * @param testExamPageQueryDTO
     * @return
     */
    @GetMapping("/pageQuery")
    public Result<PageResult> pageQuery(TestExamPageQueryDTO testExamPageQueryDTO){
        log.info("分页查询测试试卷：{}", testExamPageQueryDTO);
        PageResult pageResult = testExamService.pageQuery(testExamPageQueryDTO);
        return Result.success("", pageResult);
    }
}
